<template>
  <div class="app-container">
    <div class="filter-container">
      <el-form :inline="true" :model="formModel">
        <el-row class="submit-area">
          <el-col :span="24">
            <el-button v-if="hasPermission('sortRuleZZ_select')" type="primary" plain @click="queryList(false)">查询
            </el-button>
            <el-button v-if="hasPermission('sortRuleZZ_add')" type="primary" plain @click="handleAdd">新增</el-button>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <hey-table ref="table" :table-data="tableData" :columns="columns" :is-select="false" :auto-width="false">
      <template slot="tools">
        <el-table-column
          label="操作"
          width="160"
          fixed="right"
          header-align="center"
          align="center"
        >
          <template slot-scope="{row}">
            <span v-if="hasPermission('sortRuleZZ_edit',row)" class="hey_tools_btn" @click="handleEdit(row)">编辑</span>
            <span v-if="hasPermission('sortRuleZZ_delete',row)" class="hey_tools_btn" @click="handleDelete(row)">删除</span>
          </template>
        </el-table-column>
      </template>
    </hey-table>
    <el-dialog
      v-if="dialogVisible"
      :close-on-click-modal="false"
      title="入涂排序规则"
      :visible.sync="dialogVisible"
      width="60%"
    >
      <SortRuleTZ-mnt :page-type="operType" :edit-data="editData" @mntSuc="queryList" />
    </el-dialog>

  </div>
</template>

<script>
export default {
  name: 'SortRuleZZList',
  components: {
    SortRuleTZMnt: () => import('./sortRuleZZ-mnt')
  },
  props: {},
  data() {
    return {
      dialogVisible: false,
      operaType: '',
      editData: {},
      tableData: [],
      formModel: {
        sortRuleType: 'ZZ'
      },
      columns: [
        { title: '优先级', key: 'priorityDataKey', clcd: 'key_priority_type' },
        { title: '排序规则', key: 'collationDataKey', clcd: 'key_sort_rule' },
        { title: '阈值最小值', key: 'limitMin' },
        { title: '阈值最大值', key: 'limitMax' },
        { title: '状态', key: 'status', clcd: 'is_effective_cd' }
      ]
    }
  },
  computed: {},
  mounted() {
  },
  methods: {
    queryList() {
      this.$refs.table.query('/sortRule/pageSortRule', this.formModel, '', false)
    },
    handleAdd() {
      this.operType = 'add'
      this.dialogVisible = true
    },
    handleEdit(row) {
      this.dialogVisible = true
      this.operType = 'edit'
      this.editData = row || {}
    },
    handleDelete(row) {
      this.$sure('确认删除？', _ => {
        this.post('sortRule/deleteSortRule', { sortRuleId: row.sortRuleId }).then(_ => {
          this.$info('删除成功', this.queryList)
        })
      })
    }
  }
}
</script>

